package example.helloworld;

import grpc.htsoft.helloworld.GreeterGrpc;
import grpc.htsoft.helloworld.HelloReply;
import grpc.htsoft.helloworld.HelloRequest;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;

public class client2 {

public static void main(String[] args) {
        // 输出一个hi
        System.out.println("Hello world!");
    ManagedChannel channel = ManagedChannelBuilder.forTarget("localhost:8080/helloworld.Greeter/SayHello")
            .usePlaintext()
            .build();
    GreeterGrpc.GreeterBlockingStub stub =
            GreeterGrpc.newBlockingStub(channel);
    HelloRequest request1 = HelloRequest.newBuilder().setName("John").build();
    HelloReply response2 = stub.sayHello(request1);
    System.out.println(response2.getMessage());

    channel.shutdown();

}


}
